package com.hpeng.gl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hpeng.gl.dao.StaffDao;
import com.hpeng.gl.service.StaffService;
import com.hpeng.sys.model.Staff;
import com.hpeng.util.Pagination;

@Component("staffService")
public class StaffServiceImpl implements StaffService {
	/*spring里面注入StaffDao*/
	    @Resource
		private StaffDao staffDao;

		public Staff addStaff(Staff staff) {
			Staff sta =null;
			try {
				sta = staffDao.save(staff);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return sta;
		}

		public void delStaff(Staff staff) {
	         staffDao.remove(staff.getStaid());
		}

		public List<Staff> findStaff() {
			return staffDao.getAll();
		}

		public Staff findStaffByStaid(String staid) {
			return staffDao.get(staid);
		}

		public void updateStaff(Staff staff) {
	          staffDao.update(staff);
		}

		public Pagination<Staff> getPagination(int pageNumber,String[] hql,String[] values,String order){
			return staffDao.getPagination(pageNumber, hql,values, order);
		}
	}
